package com.yaowk.sfp.file.server.controller;

import com.yaowk.sfp.common.base.PageReq;
import com.yaowk.sfp.common.base.PageResp;
import com.yaowk.sfp.file.api.FileApi;
import com.yaowk.sfp.file.api.IFileUtils;
import com.yaowk.sfp.file.api.model.FileModel;
import com.yaowk.sfp.file.server.service.IFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 小凯
 **/
@RestController
@Api(tags = "文件管理")
public class FileController implements FileApi {

    @Autowired
    private IFileUtils fileUtils;
    @Autowired
    private IFileService fileService;

    @Override
    @ApiOperation("文件上传")
    public FileModel upload(MultipartFile file) {
        return fileUtils.upload(file);
    }

    @Override
    @ApiOperation("查询文件")
    public FileModel findOne(Long id) {
        return fileService.findById(id);
    }

    @Override
    @ApiOperation("搜索文件列表")
    public PageResp<FileModel> findAll(FileModel fileModel, PageReq pageReq) {
        return fileService.findAll(fileModel, pageReq);
    }
}
